import WaterMark from 'l-watermark'

/**
 * base64图片加水印
 */
export const addWatermark = ({ target, text }: { target: string; text: string }): Promise<string> =>
  new Promise((ok, no) => {
    try {
      WaterMark.image({
        target,
        text,
        color: 'rgba(0, 0, 0, 0.2)',
        fontSize: 14,
        cSpace: text.length * 10,
        success: (e: string) => {
          ok(e)
        },
      })
    } catch (error) {
      no('')
    }
  })
